/**  
 * @Project: zhenai_hn_v2
 * @Package com.zhenai.hn.commons.utils
 * @Title: PropertiesUtil.java
 * @Description: TODO
 *
 * @author: xiegenhua
 * @date 2015年3月25日 下午2:12:45
 * @Copyright: ZHENAINET Co.,Ltd. All rights reserved.
 * @version V1.0   
 */
package com.goicter.commons.utils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class PropertiesUtil {
	
	private String environment ;
	
	private PropertiesUtil(){
		if(environment==null||environment.equals("")){
			environment = getUrl("photo.properties", "environment");
		}
	}
	
	public static String getUrl(String fileName, String key) {
		
		Properties pro = new Properties();
		InputStream in = PropertiesUtil.class.getResourceAsStream("/" + fileName);
		String url = "";
		try {
			pro.load(in);
			url = pro.getProperty(key, "#");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return url;
	}
	private static class PropertiesHander{
		private static PropertiesUtil propUtil = new PropertiesUtil();
	}
	
	public static PropertiesUtil getInstant(){
		return PropertiesHander.propUtil;
	}
	public String getEnvironment() {
		return environment;
	}

}
